package com.sky.mapper;

import com.sky.anno.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    /**
     * 插入菜品数据
     * @param dish
     */
    @AutoFill(value = OperationType.INSERT) //添加公用字段
    void insert(Dish dish);

    /**
     * 查询总数
     * @param dishPageQueryDTO
     * @return
     */
    @Select("select count(*) from dish")
    Long count(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 分页查询
     */
    List<DishVO> selectByPage(DishPageQueryDTO dishPageQueryDTO, Integer start);

    /**
     * 根据id查询菜品
     * @param id
     * @return
     */
    @Select("select * from dish where id = #{id}")
    DishVO selectById(Long id);

    /**
     * 根据分类id查询菜品
     * @param categoryid
     * @return
     */
    @Select("select * from dish where category_id = #{categoryid}")
    List<DishVO> selectByCategoryId(Long categoryid);

    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);

    void delete( List<Long> ids);

    List<Integer> selectStatusByIds(List<Long> ids);

}
